@ -1,203 +0,0 @@
<template>
	<view class="container">
		<swiper style="height: 350rpx;" circular="true" :indicator-dots="swiperInfo.indicatorDots" :autoplay="swiperInfo.autoplay" :interval="swiperInfo.interval" :duration="swiperInfo.duration">
			<swiper-item v-for="i in swiperInfo.background" @click="swiperClick(i)">
				<view class="swiper-item">
					<image style="width: 100%;" :src="i.PicUrl" mode="aspectFill" lazy-load="true"></image>
				</view>
				<view>
					<text class="age-title" style="position: absolute;left: 13rpx;top: 13rpx;">{{i.Title}}</text>
				</view>
			</swiper-item>
		</swiper>
		<!-- 每周更新列表 -->
		<view class="age-card uni-flex uni-column uni-margin-warp uni-common-mt">
			<!-- 标题 -->
			<view class="uni-flex uni-row uni-padding-warp uni-common-mt">
				<image src="../../../static/week.png" style="width: 40rpx; height: 40rpx;"></image>
				<view style="height: 40rpx;" class="uni-flex uni-center"><text class="age-title" style="margin-left: 10rpx;">每周放送列表</text></view>
			</view>
			<!-- 分段器 -->
			<uni-segmented-control activeColor="#fff" :current="currentSegment" :values="segments" style-type="text" @clickItem="clickItem"></uni-segmented-control>
			<!-- 放松列表，根据分段器切换修改内容 -->
			<agelist :listdata="homelist" @clicklistItem="clicklistItem"></agelist>
			<!-- <scroll-view show-scrollbar="false" scroll-y="true" style="height: 500rpx;">
				<agelist :listdata="homelist" @clicklistItem="clicklistItem"></agelist>
			</scroll-view> -->
			
		</view>
		
		<!-- 推荐 -->
		<view class="age-card uni-flex uni-column uni-margin-warp uni-common-mt">
			<view class="uni-flex uni-row uni-padding-warp uni-common-mt">
				<image src="../../../static/recommend.png" style="width: 40rpx; height: 40rpx;"></image>
				<view class="uni-flex"><text class="age-title" style="margin-left: 10rpx; height: 40rpx;line-height: 40rpx;">每日推荐</text></view>
			</view>
			<view class="uni-flex uni-row" style="width: 100%; flex-wrap: wrap;margin-bottom: 10rpx;">
				<agereccell @clickCellItem="clickCellItem" style="width: 33.33%;" :recommendData="rec" v-for="rec in recommendlist"></agereccell>
			</view>
		</view>
		<view class="uni-space-item"></view>
		<ageloading v-show="isloading" color="transparent"></ageloading>
		
	</view>
</template>

<script>
	import ageloading from "@/pages/component/loading/age-loading.vue"
	import agelist from "@/pages/component/agelist/age-list.vue"
	import agereccell from "@/pages/component/ageRecCell/ageRecCell.vue"
	export default {
		components: {
			ageloading,
			agelist,
			agereccell
		},
		data() {
			return {
				jsonData:{},
				swiperInfo:{
					"background":[],
					"indicatorDots":true,
					"autoplay":true,
					"interval":2000,
					"duration":500
				},
				isloading: true,
				currentSegment: 0,
				segments: ["周日","周一","周二","周三","周四","周五","周六"],
				weeklist: [],
				homelist: [],
				recommendlist:[],
				firstload: true
			}
		},
		methods: {
			swiperClick(item){
				uni.navigateTo({
					url: `/pages/animeDetailPage/animeDetailPage?id=${item.AID.toString()}`,
					success(res) {
						console.log(res)
					},
					fail(error) {
						console.log(error)
					}
				})
			},
			// 点击每周列表
			clicklistItem(item) {
				console.log(item.id)
				uni.navigateTo({
					url: `/pages/animeDetailPage/animeDetailPage?id=${item.id.toString()}`,
					success(res) {
						console.log(res)
					},
					fail(error) {
						console.log(error)
					}
				})
			},
			clickCellItem(itemid) {
				uni.navigateTo({
					url: `/pages/animeDetailPage/animeDetailPage?id=${itemid.toString()}`,
					success(res) {
						console.log(res)
					},
					fail(error) {
						console.log(error)
					}
				})
			},
			// 分段器的选择
			clickItem(item) {
				let index = item["currentIndex"];
				this.currentSegment = index;
				this.updatehomelist(index.toString());
			},
			
			// 隐藏加载
			hideloading(){
				this.isloading = false;
			},
			
			// 删除已完结的数据
			updatehomelist(day){
				const list = this.weeklist[day];
				var newlist = new Array();
				for(let item of list) {
					if (!item.namefornew.includes('完结')) {
						newlist.push(item);
					}
					
				}
				this.homelist = newlist;
			},
			
			// 接口数据加载
			loadData(){
				const vm = this;
				// let url = "http://aiteach.lancooedu.com/Base/WS/Service_Basic.asmx/WS_G_GetSubSystemServerInfo?sysID=P12&subjectID=C"
				// let proxyurl =  "/Base/WS/Service_Basic.asmx/WS_G_GetSubSystemServerInfo?sysID=P12&subjectID=C"
				// uni.request({
				// 	url: proxyurl,
				// 	method:"GET",
				// 	success(res) {
				// 		console.log(res);
				// 		vm.hideloading();
				// 		uni.stopPullDownRefresh()
				// 		uni.showToast({
				// 			title:"接口22请求完成！"
				// 		})
				// 	},
				// 	fail(error) {
				// 		console.log(error);
				// 		vm.hideloading();
				// 		uni.stopPullDownRefresh()
				// 		uni.showToast({
				// 			title:"接口请求未完成！"
				// 		})
				// 	}
				// })
				
				let url2 = "https://ageapi.omwjhz.com:18888"
				console.log(vm.$myGlobalUrl + '/v2/slipic')
				uni.request({
					// 获取banner图数据
					url:vm.$myGlobalUrl + '/v2/slipic',
					method:"GET",
					success(res) {
						vm.swiperInfo.background = res.data;
						console.log(res.data);
						uni.request({
							url:vm.$myGlobalUrl + '/v2/home-list',
							method:'GET',
							success(res2) {
								// 每周
								vm.weeklist = res2.data["week_list"];
								// 推荐
								vm.recommendlist = res2.data["recommend"];
								console.log(vm.recommendlist)
								
								if (vm.firstload) {/// 第一次调用使用当前日期
									const today = new Date();
									const dayofweek = today.getDay();
									vm.currentSegment = dayofweek;
									vm.updatehomelist(dayofweek.toString());
									vm.firstload = false;
								} else { //
									vm.updatehomelist(vm.currentSegment.toString())
								}
								
								vm.hideloading();
								uni.stopPullDownRefresh()
							},
							fail() {
								vm.hideloading();
								uni.stopPullDownRefresh()
								uni.showToast({
									title:"接口请求失败！"
								})
							}
						})
					},
					fail() {
						vm.hideloading();
						uni.stopPullDownRefresh()
						uni.showToast({
							title:"接口请求失败！"
						})
					}
				})
			}
		},
		mounted() {
			this.loadData()
		},
		// 监听刷新
		onPullDownRefresh() {
			this.loadData()
		}
	}
</script>

<style>
	.container {
		padding: 0px;
		margin: 0px;
		line-height: 24px;
	}
	
	.age-card {
		background-color: rgb(32, 32, 32);
		border-radius: 8rpx;
		border: 1rpx solid rgb(32, 32, 32);
	}
	
</style>